package com.jspgou.cms.manager.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jspgou.common.hibernate3.Updater;
import com.jspgou.common.page.Pagination;
import com.jspgou.cms.dao.ReportTypeDao;
import com.jspgou.cms.entity.ReportType;
import com.jspgou.cms.manager.ReportTypeMng;

@Service
@Transactional
public class ReportTypeMngImpl implements ReportTypeMng {
	@Transactional(readOnly = true)
	public Pagination getPage(int pageNo, int pageSize) {
		Pagination page = dao.getPage(pageNo, pageSize);
		return page;
	}

	@Transactional(readOnly = true)
	public ReportType findById(Long id) {
		ReportType entity = dao.findById(id);
		return entity;
	}
	
	public List<ReportType> getListByDisable(Boolean disable){
		return dao.getListByDisable(disable);
	}

	public ReportType save(ReportType bean) {
		dao.save(bean);
		return bean;
	}

	public ReportType update(ReportType bean) {
		Updater<ReportType> updater = new Updater<ReportType>(bean);
		ReportType entity = dao.updateByUpdater(updater);
		return entity;
	}

	public ReportType deleteById(Long id) {
		ReportType bean = dao.deleteById(id);
		return bean;
	}
	
	public ReportType[] deleteByIds(Long[] ids) {
		ReportType[] beans = new ReportType[ids.length];
		for (int i = 0,len = ids.length; i < len; i++) {
			beans[i] = deleteById(ids[i]);
		}
		return beans;
	}

	private ReportTypeDao dao;

	@Autowired
	public void setDao(ReportTypeDao dao) {
		this.dao = dao;
	}
}